#ifndef RULEBAR
#define RULEBAR

#include <QtWidgets>

QT_BEGIN_NAMESPACE
class QFrame;
class QPaintEvent;
class QPainter;
class QGraphicsView;
QT_END_NAMESPACE

#define RULER_SIZE 16

class QtCornerBox : public QWidget {
  Q_OBJECT

 public:
  explicit QtCornerBox(QWidget *parent = NULL);

 protected:
  void paintEvent(QPaintEvent *);
};

class QtRuleBar : public QWidget {
  Q_OBJECT

 public:
  explicit QtRuleBar(Qt::Orientation direction, QGraphicsView *view,
                     QWidget *parent = NULL);
  void setRange(double lower, double upper, double max_size);
  void updatePosition(const QPoint &pos);

 protected:
  void paintEvent(QPaintEvent *event);
  void drawTicker(QPainter *painter);
  void drawPos(QPainter *painter);
  Qt::Orientation m_direction;
  QPoint m_lastPos;
  QGraphicsView *m_view;
  QColor m_faceColor;

  double m_lower;
  double m_upper;
  double m_maxsize;
};

#endif  // RULEBAR
